<!DOCTYPE html>
<html lang="en" class="app">
<head>
  <meta charset="utf-8" />
  <title>Notebook | Web Application</title>
  <meta name="description" content="app, web app, responsive, admin dashboard, admin, flat, flat ui, ui kit, off screen nav" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <link rel="stylesheet" href="${base}/rs/css/bootstrap.4.0.css" type="text/css" />
  <link rel="stylesheet" href="${base}/rs/css/app.v2.css" type="text/css" />
  <link rel="stylesheet" href="${base}/rs/css/bootstrap-table.css" type="text/css" />
  <style type="text/css">
    html,body{
      background-color: #ffffff;
    }
  </style>
</head>

<body>
<section class="panel-default">
  <div class="panel-body">
    <form class="bs-example form-horizontal" action="UpdateOrAddEntity" method="post">
      <input type="hidden" class="form-control" id="menuId" name="menuId" value="${msgMenu.menuId}" />
      <input type="hidden" class="form-control" id="menuParentId" name="menuParentId" value="${msgMenu.menuParentId}" />

      <input type="hidden" class="form-control" id="type" name="type" value="${type}" />
      <div class="form-group">
        <label class="col-xs-3 control-label col-sm-offset-2" style="text-align:right;">菜单名称:</label>
        <div class="col-xs-8 col-sm-offset-2">
          <input type="text" class="form-control" id="name" name="name" value="${msgMenu.name}" placeholder="请输入菜单名称">
        </div>
      </div>

      <div class="form-group">
        <label class="col-xs-3 control-label col-sm-offset-2" style="text-align:right;">菜单连接:</label>
        <div class="col-xs-8 col-sm-offset-2">
          <input type="text" class="form-control" id="url" name="url" value="${msgMenu.url}" placeholder="请输入菜单连接">
        </div>
      </div>

      <div class="line line-dashed line-lg pull-in"></div>
      <div class="form-group" >
        <div class="col-sm-12 col-sm-offset-2" style="text-align: center;">
          <button type="button" onclick="parentLayerClose()" class="btn btn-default">取消</button>
          &nbsp;&nbsp;
          <button type="button" onclick="updateOrAdd()" class="btn btn-primary">确定</button>
        </div>

      </div>
    </form>
  </div>
</section>
<script src="${base}/rs/js/jquery-3.2.0.min.js"></script>
<script src="${base}/rs/js/layer/layer.js"></script>
<script src="${base}/rs/js/layer/commont.js"></script>
<script src="${base}/rs/js/bootstrap.4.0.js"></script>
<script src="${base}/rs/js/bootstrap-table.js"></script>
<script src="${base}/rs/js/bootstrap-table-zh-CN.js"></script>
<script type="text/javascript">
    /**
     * 添加或修改
     */
    function updateOrAdd() {
        var name=$("#name").val();
        var url=$("#url").val();
        var menuId=$("#menuId").val();
        var menuParentId=$("#menuParentId").val();
        var type=$("#type").val();
        if(name==null || "" == name){
            layer.alert("请输入菜单名称");
            return false;
        }
        if(url==null || "" == url){
            layer.alert("请输入菜单连接");
            return false;
        }

        $.ajax({
            type: "POST",
            url: "/msgMenu/UpdateOrAddEntity",
            data: {"menuId":menuId,"name":name,"url":url,"menuParentId":menuParentId,"type":type},
            success: function(result){
                parentLayerClose();
            },
            error: function(result){
                parent.showLayerAlert(result);

            }
        });
    }

    function parentLayerClose() {
        var index=parent.layer.getFrameIndex(window.name);//获取layer的索引
        parent.$('.msgmenuclass').bootstrapTable("refresh");
        parent.layer.close(index);
    }

</script>
</body>
</html>
